<!DOCTYPE html>
<html>

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no" />
		<meta content="yes" name="apple-mobile-web-app-capable" />
		<meta content="black" name="apple-mobile-web-app-status-bar-style">
		<meta content="telephone=no" name="format-detection" />
		<meta content="emai=no" name="format-detection" />
		<link rel="stylesheet" type="text/css" href="/wc/css/common.css" />
		<link rel="stylesheet" type="text/css" href="/wc/css/form.css" />
		<link rel="stylesheet" type="text/css" href="/wc/css/apply.css" />
		<script type="text/javascript" src="/wc/js/jquery-1.11.2.min.js"></script>
		<script type="text/javascript" src="/wc/js/underscore.js"></script>
		<script type="text/javascript" src="/wc/js/pinchzoom.js"></script>
		<title>芝士妈妈在线</title>
	</head>

	<body>
		<div class="wrapper">
			<form action="/agent/test" method="post">
				<h2>无创代理申请</h2>
				<section class="flex-wrapper flex-align-center">
					<label>手机号：</label>
					<p class="flex-1">
						<input type="tel" maxlength="13" id="mobile" name="mobile" value="" data-message="请输入手机号！" />
					</p>
				</section>
				<section class="flex-wrapper flex-align-center">
					<label>验证码：</label>
					<p class="flex-1">
						<input type="number" maxlength="8" id="code" name="code" value="" placeholder="" data-message="请输入验证码！" />
						<button type="button" id="geticode" class="special">获取验证码</button>
					</p>
				</section>
				<button type="submit" id="btn" class="btn btn-red">确 认</button>
			</form>
		</div>
		<div class="hide popup-map">
			<div class="pinch-zoom">
				<img src="/wc/img/map.jpg" alt="" />
			</div>
		</div>
		<script src="/wc/js/common.js" type="text/javascript"></script>
		<script type="text/javascript">
			$(function() {
                var enalbeGeticode = true;
                if ($('#geticode').length > 0) {
                    $('#geticode').click(function (e) {
                        zsmm.isValidated = true;
                        validateInput("mobile");
                        validatePhone("mobile");
                        if (!zsmm.isValidated) {
                            return false;
                        }
                        var mobile = $.trim( $('#mobile').val() );
                        if (enalbeGeticode) {
                            enalbeGeticode = false;
                            var i = 60;
                            var obj = $(this);
                            obj.text(i + '秒后重试').addClass('disabled');
                            var intval = setInterval(function () {
                                i -= 1;
                                obj.text(i + '秒后重试');
                                if (i <= 0) {
                                    clearInterval(intval);
                                    obj.text('获取短信验证码').removeClass('disabled');
                                    enalbeGeticode = true;
                                    return;
                                }
                            }, 1000);
                            $.ajax({
                                type : "get",
                                url : "/agent/send",
                                data : {"mobile" : mobile},
                                dataType:'json',
                                success : function( rs ) {
                                    zsmm.Toast.New(rs.msg);
                                }
                            });
                        }
                    });
                }

                $("button[type='submit']").click(function(e) {
                    e.preventDefault();
                    zsmm.isValidated = true;
                    var code = $.trim( $('#code').val() );
                    var mobile = $.trim( $('#mobile').val() );
                    validateInput("code");
                    //ajax校验验证码
                    $.ajax({
                        type : "get",
                        url : "/agent/validcode",
                        data : {"code" : code, 'mobile': mobile},
                        dataType:'json',
                        success : function(res) {
                            if(res.error == 0) {
                                $("form").submit();
                            } else {
                                zsmm.Toast.New(res.msg);
                            }
                        }
                    });
                });
            });


        </script>
	</body>

</html>